package com.cxhc.app.api.hcdoc;


import com.cxhc.app.api.hcdoc.vo.HdApprovalFormVo;
import com.cxhc.app.api.hcdoc.vo.HdProjectInfoVo;
import com.cxhc.app.api.mapper.hcdoc.HdApprovalFromMapStructMapper;
import com.cxhc.app.api.mapper.hcdoc.HdProjectInfoMapStructMapper;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.core.page.TableDataInfo;
import com.cxhc.common.utils.StringUtils;
import com.cxhc.system.domain.hcdoc.HdApprovalForm;
import com.cxhc.system.domain.hcdoc.HdProjectInfo;
import com.cxhc.system.service.hcdoc.HdApprovalFormService;
import com.cxhc.system.service.hcdoc.HdProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目信息Controller
 *
 * @author Dhq
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/api/hcDoc/approvalForm")
public class HdApprovalFormApi extends BaseController {

    @Autowired
    private HdApprovalFormService hdApprovalFormService;

    /**
     * 获取项目信息详细信息 之后写
     */
    @RequestMapping(value = "/getInfoId")
    public AjaxResult getInfoId(String id) {
        return success(hdApprovalFormService.selectById(id));
    }

    /**
     * 新增项目信息
     */
    @RequestMapping("/insert")
    public AjaxResult insert(@RequestBody HdApprovalFormVo hdApprovalFormVo) {
        HdApprovalForm hdApprovalForm = HdApprovalFromMapStructMapper.INSTANCE.HdApprovalFormVoToHdApprovalForm(hdApprovalFormVo);
        return toAjax(hdApprovalFormService.insert(hdApprovalForm));
    }

    /**
     * 查询项目信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HdApprovalFormVo hdApprovalFormVo) {
        HdApprovalForm hdApprovalForm = HdApprovalFromMapStructMapper.INSTANCE.HdApprovalFormVoToHdApprovalForm(hdApprovalFormVo);
        startPage();
        return getDataTable(hdApprovalFormService.selectList(hdApprovalForm));
    }

    /**
     * 审批
     */
    @RequestMapping("/approval")
    public AjaxResult update(@RequestBody HdApprovalFormVo hdApprovalFormVo) {
        HdApprovalForm hdApprovalForm = HdApprovalFromMapStructMapper.INSTANCE.HdApprovalFormVoToHdApprovalForm(hdApprovalFormVo);
        return toAjax(hdApprovalFormService.approval(hdApprovalForm));
    }

}
